﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WAD.Model;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;
using System.Data;

namespace WAD.DAL
{
    /// <summary>
    /// 短信验证码数据库操作
    /// </summary>
    public class DaoSmsCode : DAO
    {
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public static bool Add(MSmsCode m)
        {
            String sql = "insert into sms_code(phone,code,sign,state,error_msg)values(@phone,@code,@sign,@state,@error_msg)";
            Database db = GetDatabase();
            DbCommand cmd = db.GetSqlStringCommand(sql);
            db.AddInParameter(cmd, "@phone", DbType.String, m.phone);
            db.AddInParameter(cmd, "@code", DbType.String, m.code);
            db.AddInParameter(cmd, "@sign", DbType.String, m.sign);
            db.AddInParameter(cmd, "@state", DbType.String, m.state);
            db.AddInParameter(cmd, "@error_msg", DbType.String, m.error_msg);
            return db.ExecuteNonQuery(cmd) > 0;
        }
    }
}
